﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace Golf.WebUI.AdminShow.OrderManagement
{
    public partial class Golf_BankModify : Golf.WebUI.App_code.ValidateLogin
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int Id = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(Id);
                }
            }
        }

        private void ShowInfo(int Id)
        {
            Golf.BLL.Golf_Bank bll = new Golf.BLL.Golf_Bank();
            Golf.Model.Golf_Bank model = bll.GetModel(Id);
            this.lblId.Text = model.Id.ToString();
            this.txtBankName.Text = model.BankName;
            this.txtAdminId.Text = model.AdminId.ToString();
            this.txtAddTime.Text = model.AddTime.ToString();

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtBankName.Text.Trim().Length == 0)
            {
                strErr += "银行名称不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtAdminId.Text))
            {
                strErr += "添加管理人id Golf_Ad格式错误！\\n";
            }
            if (!PageValidate.IsDateTime(txtAddTime.Text))
            {
                strErr += "添加时间格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int Id = int.Parse(this.lblId.Text);
            string BankName = this.txtBankName.Text;
            int AdminId = int.Parse(this.txtAdminId.Text);
            DateTime AddTime = DateTime.Parse(this.txtAddTime.Text);


            Golf.Model.Golf_Bank model = new Golf.Model.Golf_Bank();
            model.Id = Id;
            model.BankName = BankName;
            model.AdminId = AdminId;
            model.AddTime = AddTime;

            Golf.BLL.Golf_Bank bll = new Golf.BLL.Golf_Bank();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
